package actioncombination.logic.simulator;

import actioncombination.logic.agent.Agent;
import actioncombination.logic.agent.GoalBasedAgent;
import actioncombination.logic.agent.Perception;
import actioncombination.logic.agent.RLAgent;
import actioncombination.logic.agent.action.Action;
import actioncombination.logic.agent.GoalTest;

import actioncombination.logic.agent.AgentState;
import actioncombination.logic.environment.Environment;
import actioncombination.logic.environment.RLEnvironment;
import java.util.Vector;

public class RLSimulator {

    protected Vector<RLAgent> agents;
    protected RLEnvironment environment;

    public RLSimulator(RLEnvironment environment, Vector<RLAgent> agents) {
        this.environment = environment;
        this.agents = agents;
    }

    public RLSimulator(RLEnvironment environment, RLAgent agent) {
        Vector<RLAgent> ags = new Vector<RLAgent>();
        ags.add(agent);

        this.environment = environment;
        this.agents = ags;
    }

    public void addAgent(RLAgent agent) {
        this.getAgents().addElement(agent);
    }

    public Vector<RLAgent> getAgents() {
        return agents;
    }

    public Environment getEnvironment() {
        return this.environment;
    }

    public Perception getPercept(RLAgent agent) {
        return this.getEnvironment().getPercept(agent);
    }

    public void setEnvironment(RLEnvironment evm) {

    }

    public void start(int episodes) {
        //TODO:
        // ANTES DE EMPEZAR CON LA SIMULACION HAY QUE TESTEAR QUE EL AMBIENTE ESTE
        // INICIALIZADO, ETC.			

        for (RLAgent agent : this.getAgents()) {

            for (int i = 0; i < episodes; i++) {
                agent.BeginEpisode();
            }
        }
    }

    public void showSolution() {
       
		
    }

}
